<?php
/**
 * Created by PhpStorm.
 * User: Cloud
 * Date: 2018/3/29
 * Time: 17:41
 */
?>

<!DOCTYPE html>
<html>
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->

    <meta charset="utf-8">
    <title>个人中心（user-manager）-文具1号</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <meta name="renderer" content="webkit">
    <base href="<?php echo base_url(); ?>"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" href="public/js/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="public/css/deliver_address.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/cost-center.css"/>

    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->
</head>
<body>
<div class="bg">
    <!--common - head -->
    <?php $this->load->view('common/header.php'); ?>
    <!--common - head end-->

    <div class="container mt30">
        <div class="my-center-container">

            <?php $this->load->view('member/personal_left.php'); ?>

            <div class="my-center-right">
                <p class="my-center-right-tit">收货地址</p>
                <div class="my-center-right-cont">
                    <div id="main-content" class="account-security security-deliver">
                        <form method="post" action="" id="hidef" name="hidef">

                            <input type="hidden" value="" id="addr_id" name="id">
                            <input type="hidden" value="7pf1brqSGWm" name="_tb_token_">
                            <input type="hidden" value="" id="_fm.d._0.i" name="_fm.d._0.i">

                            <input type="hidden" value="deliver_address_mgr" id="action1" name="action1">
                            <input type="hidden" value="1" id="event_submit_do_perform" name="event_submit_do_perform">
                            <h3><span class="entity-h3">新增收货地址</span>电话号码、手机号选填一项,其余均为必填项</h3>
                            <ul id="addressForm" class="elem-form section addressEditor">
                                <li>
                                    <label for="contact" class="label-like">收货人姓名:</label>
                                    <p>
                                        <input type="text" class="inputtext input-long" value="" id="contact"
                                               name="name">
                                        <span class="spark-indeed">*</span>
                                    </p>
                                </li>
                                <li><label class="label-like">所在地区:</label>
                                    <p id="admin_company_form_info" data-toggle="distpicker">
                                        <select name="province" id="province" style="width:120px;">
                                            <option value="0" selected="selected">请选择省份...</option>
                                        </select>
                                        <select name="city" id="city" style="width:120px;">
                                            <option value="0" selected="selected">请选择市...</option>
                                        </select>
                                        <select id="country" name="district" data-code="" style="width:102px;">
                                            <option value="0" selected="selected">请选择县/区...</option>
                                        </select>
                                        <input type="hidden" name="region_name" value="">
                                        <input type="hidden" name="regionId" id="regionId" value="">
                                        <span class="spark-indeed">*</span>
                                    </p>
                                </li>
                                <li><label for="add-street" class="label-like">街道地址:</label>
                                    <p>
                                        <textarea cols="60" rows="3" id="add-street" name="address"
                                                  style="padding: 4px 3px;"></textarea>
                                        <span class="spark-indeed">*</span>
                                        <span class="ex-margin-left ex-weaken-gray">不需要重复填写省/市/区</span>
                                    </p>
                                </li>
                                <li>
                                    <label for="add-postcode" class="label-like">邮政编码:</label>
                                    <input type="text" class="inputtext input-short ds:areaCode" value=""
                                           id="add-postcode" name="postcode">

                                    <span class="ex-margin-left ex-weaken-gray">请填写 6位邮政编码</span>
                                    <div class="clb"></div>
                                </li>
                                <li>
                                    <label for="add-mobil" class="label-like">手机号码:</label>

                                    <p>
                                        <input type="text" class="inputtext input-long" id="add-mobil"
                                               value="" name="phone">
                                        <span class="spark-indeed">*</span>
                                        <!-- <span class="ex-margin-left ex-weaken-gray">
                                            电话号码、手机号码必填一项
                                        </span> -->
                                    </p>
                                </li>
                                <li>
                                    <label class="label-like">电话号码:</label>
                                    <input type="text" class="inputtext input-tel-code" id="tel-code" value=""
                                           title="区号" name="tel-code"> -
                                    <input type="text" class="inputtext input-tel-num" id="tel-num" value=""
                                           title="电话号码" name="tel-num"> -
                                    <input type="text" class="inputtext input-tel-cell" id="tel-cell" value=""
                                           title="分机" name="tel-cell">
                                    <span class="ex-margin-left ex-weaken-gray">区号-电话号码-分机</span>
                                    <input type="hidden" name="tel" value="" id="tel" class="" >
                                    <div class="clb"></div>
                                </li>
                                <li>
                                    <label for="statusAddr" class="label-like">设为默认:</label>
                                    <input type="checkbox" id="statusAddr" name="is_default" value="" checked>
                                </li>
                                <li class="container-btn">
                                    <div id="createD" class="skin-gray">
                                        <button class="short-btn" id="5555" type="button">保存</button>
                                        <!--<a id="J_DeliverStation1" class="btn-deliver-station" href="">使用代收货（自提）</a>-->
                                    </div>
                                </li>
                            </ul>
                            <div class="tbl-deliver-address">
                                <table cellspacing="0" cellpadding="0" border="0" class="tbl-main">
                                    <caption>已保存的有效地址</caption>
                                    <colgroup>
                                        <col class="col-man">
                                        <col class="col-area">
                                        <col class="col-address">
                                        <col class="col-postcode">
                                        <col class="col-phone">
                                        <col class="col-actions">
                                    </colgroup>
                                    <tbody>
                                    <tr class="thead-tbl-grade">
                                        <th>收货人</th>
                                        <th>所在地区</th>
                                        <th>街道地址</th>
                                        <th>邮编</th>
                                        <th>电话/手机</th>
                                        <th></th>
                                        <th>操作</th>
                                    </tr>
                                    <?php foreach ($data as $address): ?>
                                        <tr class="thead-tbl-address <?php if ($address['is_default']): ?>default_address<?php endif; ?>"
                                            gdata-id="<?php echo $address['id'] ?>">
                                            <td class="cell-align-center name"><?php echo $address['name'] ?></td>
                                            <td class=""><?php echo $address['province'] . $address['city'] . $address['district'] ?></td>
                                            <input type="hidden" class="province"
                                                   value="<?php echo $address['province'] ?>">
                                            <input type="hidden" class="city" value="<?php echo $address['city'] ?>">
                                            <input type="hidden" class="country"
                                                   value="<?php echo $address['district'] ?>">
                                            <input type="hidden" class="postcode"
                                                   value="<?php echo $address['postcode'] ?>">
                                            <td class="address"><?php echo $address['address'] ?></td>
                                            <td class="cell-align-center"><?php echo $address['postcode'] ?> </td>
                                            <td><p class="telephone"><?php echo $address['tel'] ?></p>
                                                <p class="mobile"><?php echo $address['phone'] ?></p></td>
                                            <?php if ($address['is_default'] == 1): ?>
                                                <td class="thead-tbl-status default_address" gdata-value="1">默认地址</td>
                                            <?php else: ?>
                                                <td class="thead-tbl-status" gdata-value="0"></td>
                                            <?php endif; ?>
                                            <td class="cell-align-center">
                                                <!--                                            <a onclick="editAddress($(this))" id="-->
                                                <?php //echo $address['id']?><!--" href="javascript:void(0);">修改</a> |-->
                                                <a class="<?php echo $address['id'] ?>" id="editaddress"
                                                   href="javascript:void(0);">修改</a>
                                                <!--                                               <a onclick="delAddress($(this))" id="-->
                                                <?php //echo $address['id'] ?><!--" href="javascript:void(0);" >删除</a>-->
                                                <a id="deleteaddress" href="javascript:void(0);">删除</a>
                                            </td>
                                        </tr>
                                    <?php endforeach; ?>
                                    </tbody>
                                </table>
                                <p class="tbl-attach">最多保存20个有效地址</p>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">

    </script>
    <?php $this->load->view('common/bottom.php'); ?>

    <script type="text/javascript" src="public/js/jquery.min.js"></script>
    <script src="public/js/layui/layui.js"></script>
    <script type="text/javascript" src="public/js/index.js"></script>
    <script type="text/javascript" src="public/js/owl.carousel.min.js"></script>
    <!--    <script type="text/javascript" src="public/js/region.js"></script>-->
    <script type="text/javascript" src="public/js/deliver_address.js?v=1532487253"></script>
    <script type="text/javascript" src="public/js/distpicker/distpicker.data.js "></script>
    <script type="text/javascript" src="public/js/distpicker/distpicker.js"></script>
    <script type="text/javascript">
        $('#admin_company_form_info').distpicker({
            province: '请选择...',
            city: '请选择...',
            district: '请选择...',
            autoSelect: ""
        });

        //修改地址
        $(document).ready(function () {
            $('.thead-tbl-address .cell-align-center').on('click', '#editaddress', function () {
                var tr = $(this).parent().parent();
                $('#contact').val(tr.find('.name').text());

                $('#province').val(tr.find('.province').val());
                $("#province").trigger("change");


                $('#city ').val(tr.find('.city').val());
                $("#city").trigger("change");
                $('#country').val(tr.find('.country').val());

                $('#add-street').val(tr.find('.address').text());
                $('#add-postcode').val(tr.find('.postcode').val());
                $('#add-mobil').val(tr.find('.mobile').text());
                var tel = tr.find(".telephone").text();
                $('#tel').val(tel);
                $('#tel-code').val(tel.substr(0, 5));
                $('#tel-num').val(tel.substr(5, 8));
                $('#tel-cell').val(tel.substr(13, 8));
                if (tr.find('.default_address').attr('gdata-value') == 1) {
                    $('#statusAddr').prop("checked", "checked");
                } else {
                    $("#statusAddr").removeAttr("checked");
                }
                $('#statusAddr').val(tr.find('.default_address').attr('gdata-value'));
                $('#addr_id').val(tr.attr('gdata-id'));
                return true;
            });
            //删除地址
            $('.thead-tbl-address .cell-align-center').on('click', '#deleteaddress', function () {
                var tr = $(this).parent().parent();
                var id = tr.attr('gdata-id');
                $.ajax({
                    type: "post",
                    dataType: "json",
                    url: "member/address_del",
                    data: {'id': id},
                    success: function (data) {
                        if (data.code == 0) {
                            layer.msg(data.msg);
                            setTimeout(function () {
                                window.location.reload();
                            }, 2000)
                        } else {
                            layer.msg(data.msg)
                        }
                    }
                });
            });
        });

    </script>
    <style type="text/css">
        .elem-form .inputtext, .elem-form textarea {
            background-attachment: scroll;
            background-color: rgba(0, 0, 0, 0);
            background-image: url('<?php echo base_url();?>public/images/bg_input_text.png');
            background-repeat: no-repeat;
        }
    </style>
</body>
</html>